package com.demo.readers;

import com.demo.common.model.Readers;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.SqlPara;

public class ReaderService {

    private Readers dao=new Readers().dao();

    public Page<Readers> paginate(int pageNumber, int pageSize) {
        return dao.paginate(pageNumber, pageSize, "select *", "from readers order by id asc");
    }

    public Page<Readers> paginate(int pageNumber, int pageSize, Kv cond) {
        SqlPara sqlPara = dao.getSqlPara("searchReaders",cond);
        return dao.paginate(pageNumber, pageSize, sqlPara);
    }

    public Readers findById(int id) {
        return dao.findById(id);
    }

    public Readers findFirstByReaderNo(String readerNo){
        String sql="select * from readersview where readerno='"+readerNo+"'";
        return dao.findFirst(sql);
    }

    public void deleteById(int id) {
        dao.deleteById(id);
    }
}
